<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>剪贴板</title>
</head>
<body>
  <div>
    <p id="text">操你妈</p>
    <button id="copy">复制</button>
  </div>
  <script>
    const {clipboard} = require('electron')
    const text = document.querySelector('#text')
    const btn = document.querySelector('#copy')

    btn.onclick = () => {
      clipboard.writeText(text.innerHTML)
    }
  </script>
</body>
</html>